<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>浏览申请记录</title>
</head>
<body>
	<div class="easyui-panel" data-options="fit:true,border:0">
		<div id="" class="easyui-layout" data-options="fit:true">
			<div data-options="region:'nouth',split:true" style="width:100%;height:70%;border-left:0;">
				<div id="applyRecordBar">
				  <span class="paddingTBL"> 
					    <div class="paddingB">
					        <select class="easyui-combobox" id="applyRecord_type" data-options="width:115,height:'auto'">
					            <option value="0">申请日期</option>
					            <option value="1">出院日期</option>
							</select>
							<input type="text" class="easyui-datebox" id="applyRecord_date1" data-options="width:115,height:24"/>
							<label>&nbsp;至&nbsp;</label>
							<input type="text" class="easyui-datebox" id="applyRecord_date2" data-options="width:115,height:24"/>
							
							<label class="paddingL">申请目的&nbsp;</label>
							<input type="text" class="" id="applyRecord_purpose" data-options="width:120,height:24"/>
							<label class="paddingL">审批状态&nbsp;</label>
							<select class="easyui-combobox" id="applyRecord_status" data-options="width:120,height:'auto'">
								<option value="0" selected="selected">全部</option>
					            <option value="1" >中间流程</option>
					            <option value="2" >批准</option>
					            <option value="3">驳回</option>
							</select>
						</div>
						<span>
							<label>主治医生&nbsp;</label>
							<input type="text" class="" id="applyRecord_doc" data-options="width:120,height:24"/>
					    	<label class="paddingL">病案号&nbsp;</label>
							<input type="text" class="easyui-textbox" id="applyRecord_fprn" data-options="width:120,height:24"/>
							<label class="paddingL" style="width:62px;">姓&nbsp;名&nbsp;</label>
							<input type="text" class="easyui-textbox" id="applyRecord_fname" data-options="width:120,height:24"/>
							<label class="paddingL">出院科室&nbsp;</label>
							<input type="text" class="easyui-textbox" id="applyRecord_fcydept" data-options="width:120,height:24"/>
						</span>	
					</span>
					<span class="paddingLB">
						<a href="#" class="easyui-linkbutton" onclick="applyQuery()">检 索</a>
					</span>
				</div>
				<table id="applyRecordGrid"></table>
				<!-- 预览窗口  -->
				<div id="applyRecordDialog" class="easyui-dialog"  data-options="closed:true" style="width:100%;height:100%;">
					 <!-- 该页面为公共浏览页，所以当不同的页面调用此页面时需给一个表示，通过此标识开放一定的权限 。2 ：表示浏览操作 -->
					<%-- <jsp:include page="../MedicalShootManage/Shoot.jsp" >
						<jsp:param value="2" name="tag"/>
						<jsp:param value="applyRecordDialog" name="dialog"/>
					</jsp:include> --%>
					<!-- <div  class="easyui-panel" data-options="href:ctx+'/MedicalShootManage/Shoot?tag=2&dialog=applyRecordDialog'" style="height: 100%;width:100%;"></div> -->
				</div>
			</div> 	 
				
			<div data-options="region:'south',title:'审批信息',split:true,collapsible:false" style="width:100%;height:30%;border-left:0;">
				<table id="applyDetailsGrid"></table>			
			</div>
		</div>
</div>  

<script type="text/javascript">
//获取出院科室
$("#applyRecord_fcydept").combobox({
	url:ctx + "/MedicalShootManage/getDept",
	valueField:"ftykh",
	textField:"fksname",
	width:120, 
	height:24,
	onLoadSuccess : function() {
		$('#applyRecord_fcydept').combobox('select', 'TZYQY');
	}
});

//获取主治医生
$("#applyRecord_doc").combobox({
	url:ctx + "/MedicalShootManage/getZzDoc",
	valueField:"fzzdoctbh",
	textField:"fzzdoct",
	width:120, 
	height:24
});

//获取申请目的
$("#applyRecord_purpose").combobox({
	url:ctx + "/MedicalShootManage/getSqmd",
	valueField:"fid",
	textField:"fname",
	width:120, 
	height:24
});

//查询数据
function applyQuery(){
	var type = $("#applyRecord_type").combobox("getValue");
	var date1 = $("#applyRecord_date1").datebox("getValue");
	var date2 = $("#applyRecord_date2").datebox("getValue");
	var purpose = $("#applyRecord_purpose").combobox("getValue");
	var status = $("#applyRecord_status").combobox("getValue");
	var doc = $("#applyRecord_doc").combobox("getValue");
	var fprn = $("#applyRecord_fprn").textbox("getValue");
	var fname = $("#applyRecord_fname").textbox("getValue");
	var fcydept = $("#applyRecord_fcydept").combobox("getValue");
	$("#applyRecordGrid").datagrid({
		url:ctx + "/Archiving/getApplyRecord",
		queryParams:{
			"date1" : date1,
			"date2" : date2,
			"fcydept" : fcydept,
			"fzzDoc" : doc,
			"fprn" : fprn,
			"fname" : fname,
			"type" : type,
			"status" : status,
			"purpose" : purpose,
		}
	});
};

//加载数据表格
$("#applyRecordGrid").datagrid({
	url:'',
	toolbar:"#applyRecordBar",
	fitColumns:false,
	rownumbers:true,
	border : false,
	striped : true,
	fit : true,
	singleSelect: true,
	pagination : true,
	pageSize : 20,
	pageList : [ 20, 30,50 ],
	columns:[[
        {field:'operat',title:'操作',width:80,align:'center',
        	formatter:function(value,row,index){
        		return "<button class='shootBtn' onclick='applybrowse("+index+")'>浏览</button>";
        	}
        },  
		{field:'fspzt',title:'状态',width:80,align:'center'},  
		{field:'fdqlc',title:'当前流程',width:100,align:'center'},  
		{field:'fsqrq',title:'申请时间',width:100,align:'center',
			formatter:function(value){
				return new Date(value).format("yyyy-MM-dd");
			}
		},  
		{field:'fsqdays',title:'天数',width:50,align:'center'},  
		{field:'fqsrq',title:'开始时间',width:100,align:'center',
			formatter:function(value){
				return new Date(value).format("yyyy-MM-dd");
			}
		},  
		{field:'fjsrq',title:'结束时间',width:100,align:'center',
			formatter:function(value){
				return new Date(value).format("yyyy-MM-dd");
			}	
		},  
		{field:'fprn',title:'病案号',width:120,align:'center'},  
		{field:'fzyid',title:'住院ID',width:100,align:'center'},  
		{field:'ftimes',title:'次数',width:50,align:'center' },  
		{field:'fname',title:'姓名',width:80,align:'center' },  
		{field:'fsex',title:'性别',width:50,align:'center' },  
		{field:'fbirthday',title:'出生日期',width:100,align:'center',
			formatter:function(value){
				if(value){
					return new Date(value).format("yyyy-MM-dd");
				}
			}
		},  
		{field:'fbarcode',title:'条码号',width:160,align:'center' },  
		{field:'fcydate',title:'出院日期',width:100,align:'center',
			formatter:function(value){
				return new Date(value).format("yyyy-MM-dd");
			}
		},  
		{field:'fcydept',title:'出院科室',width:100,align:'center' },
		{field:'fid',title:'ID',width:1,align:'center' ,hidden:true}
	 ]],
	 onSelect : function(index,row){
		 //根据住院ID获取病案申请详细记录
		 $("#applyDetailsGrid").datagrid({
				url:ctx + "/Archiving/getApplyDetails",
				queryParams:{
					"fid" : row.fid
				}
			});
	 }
	       
});

//加载想详情表格
$("#applyDetailsGrid").datagrid({
	url:'',
	toolbar:"#",
	rownumbers:true,
	fitColumns:true,
	border : false,
	striped : true,
	fit : true,
	singleSelect: true,
	pagination : true,
	pageSize : 20,
	pageList : [ 20, 30,50 ],
	columns:[[
		{field:'fspzt',title:'状态',width:80,align:'center'},  
		{field:'fdqlc',title:'流程名称',width:100,align:'center'},  
		/* {field:'',title:'流程类型',width:60,align:'center'}, */  
		{field:'fspy',title:'审批人',width:80,align:'center'},  
		{field:'fqsrq',title:'开始时间',width:100,align:'center',
			formatter:function(value){
				return new Date(value).format("yyyy-MM-dd");
			}	
		},  
		{field:'fjsrq',title:'结束时间',width:100,align:'center',
			formatter:function(value){
				return new Date(value).format("yyyy-MM-dd");
			}	
		},  
		{field:'fspms',title:'审批描述',width:100,align:'center'}  
	   	]]
});

//图片浏览
function applybrowse(index){
	var rows = $("#applyRecordGrid").datagrid("getRows")[index];
		$("#applyRecordDialog").dialog({
			maximizable : true,
			closed : false,
			modal : true,
			href: ctx+'/MedicalShootManage/BrowsePage?tag=2&dialog=batchListDialog&fprn='+rows.fprn + '&fzyid=' +rows.fzyid 
				+ '&ftimes='+rows.ftimes+ '&fname='+encodeURI(encodeURI(rows.fname))+ '&fcydate='+new Date(rows.fcydate).format("yyyy-MM-dd")
				+ '&fbarcode='+rows.fbarcode,
			title : '' // "拍摄"
		});
}
</script>
</body>
</html>